package com.fieldchain.ex.fa100.ui.personal.activity;

import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.fieldchain.ex.fa100.R;
import com.fieldchain.ex.fa100.base.MyBaseActivity;
import com.fieldchain.ex.fa100.bean.User;

import com.fieldchain.ex.fa100.utils.screen.MyToast;
import com.fieldchain.ex.fa100.utils.share.ShareManager;

/**
 * Created by biyunlong
 * Email: 1225198434@qq.com
 * Data:  2018/9/12
 */
public class UserSetActivity extends MyBaseActivity implements View.OnClickListener {
    private RelativeLayout reaBack;
    private TextView tvCenter;
    private RelativeLayout reaCertification;
    private RelativeLayout reaAddbank;
    private User user;
    private boolean hadAuth = false;

    @Override
    public void findView() {
        reaBack = findViewById(R.id.rea_back);
        tvCenter = findViewById(R.id.tv_center);
        reaCertification = findViewById(R.id.rea_certification);
        reaAddbank = findViewById(R.id.rea_simple_content);
    }

    @Override
    protected void onResume() {
        super.onResume();
        user = ShareManager.getInstance().getUser();
        if (user != null) {
            if (user.getIdCardAuth() == 1) {
                hadAuth = true;
            } else {
                hadAuth = false;
            }
        }
    }

    @Override
    public void setValue() {
        tvCenter.setText("个人资料");
        reaBack.setOnClickListener(this);
        reaAddbank.setOnClickListener(this);
        reaCertification.setOnClickListener(this);
    }

    @Override
    public int getLayout() {
        return R.layout.activity_userset;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.rea_back:
                finish();
                break;
            case R.id.rea_simple_content:
                if (hadAuth) {
                    startActivity(new Intent(mContext, BankActivity.class));
                } else {
                    MyToast.show("未实名认证");
                }
                break;
            case R.id.rea_certification:
                mContext.startActivity(new Intent(mContext, AuthActivity.class));
                break;
        }
    }
}
